/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.util;

import sk.jp.commons.exception.ApplicationException;
import sk.jp.commons.utils.ExceptionUtils;
import sk.jp.commons.tools.Properties;

public enum Property {

    confPlace("conf.place"),
    confPath("conf.path"),
    uiLocale("conf.locale"),
    
    defaultThumbSize("conf.default.thumb.size"),
    defaultLookAndFeel("conf.default.laf"),
    defaultMainWndWidth("conf.default.mainwnd.width"),
    defaultMainWndHeight("conf.default.mainwnd.height"),

    configDbLogfileLevel("conf.db.log.level"),

    appVersion("app.version"),
    appVersionDb("app.version.db"),
    ;

    //----------------------------------------------------------------------

    private String propKey;

    Property(String propKey) {
        this.propKey = propKey;
    }

    public String getPropKey() {
        return propKey;
    }

    /**
     * Returns property value.
     * @return property value.
     */
    public String value(){
        return Properties.getProperty(propKey);
    }

    /**
     * Returns property value as integer.
     * @return property value as integer.
     */
    public int intValue(){
        try {
            return Integer.parseInt(value());
        }catch(Exception e){
            throw new ApplicationException("Can't read property value as integer", null,
                                           ExceptionUtils.paramsToMap("property", getPropKey(),
                                                                      "value", value()),
                                           e);
        }
    }

}
